<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>新建随访组</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/common/bootstrap/css/bootstrap.css"
          media="all">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/common/global.css">
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/common/bootstrap/js/jquery-1.12.4.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/common/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jsplug/echarts.min.js"></script>
    <!-- 图表展示 -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/common/jsplug/echarts.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/common/jsplug/echarts.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/common/jsplug/jparticle.jquery.js"></script>
    <%--js--%>
    <script type="text/javascript" src="${pageContext.request.contextPath}/pageJs/grouping/addgrouping.js"></script>
    <script type="text/javascript">
        $(function () {
            var today=new Date();
            var submitTime=today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
            $("#creatorTimes").attr('value',submitTime);
            var index1 = false;
            $("#telephone").blur(function () {
                var tele = $("#telephone").val();
                var patrn = /^(13[0-9]|15[0-9]|18[0-9])\d{8}$/;
                if (patrn.test(tele) == false) {
                    alert("请填写正确的手机号!");
                    index1 = false;
                } else {
                    index1 = true;
                }
            });
            var index2 = false;
            /**
             * 验证名称是否为空
             */
            $("#gname").blur(function () {
                var gnames = $("#gname").val();
                if (gnames.trim() == null || gnames.trim() == "") {
                    alert("请填写名称");
                    index2 = false;
                } else {
                    index2 = true;
                }
            });
            var index3=false;
            $("#endTimes").blur(function () {
               var beginTimes= $("#beginTimes").val();
                var endTimes= $("#endTimes").val();
               if(endTimes<beginTimes){
                   alert("结束时间需大于开始时间!");
                   index3=false;
               }else{
                   index3=true;
               }
            });
            var index4=false;
            $("#beginTimes").blur(function () {
                var beginTimes= $("#beginTimes").val();
                var creatorTimes= $("#creatorTimes").val();
                var endTimes= $("#endTimes").val();
                if(beginTimes<creatorTimes){
                    alert("开始时间需大于创建时间!");
                    index4=false;
                }
                if(endTimes==null){
                    index4=true;
                }else{
                    if(endTimes<beginTimes){
                        alert("开始时间需小于结束时间!");
                        index4=false;
                    }else{
                        index4=true;
                    }
                }
            });
            $("#addGrouptable").click(function () {
                if(index1&&index2&&index3){
                    $("#formGrouptable").attr("action","${pageContext.request.contextPath}/group/insertGrouptable")
                    $("#formGrouptable").submit();
                }else {
                    alert("请填写正确数据！");
                }
            });
        })
    </script>
</head>
<body>
<div class="container">
    <form role="form" id="formGrouptable" method="post" action="" class="form-horizontal">
        <div class="form-group col-sm-12">
           <label for="departmentId" class="col-sm-2 control-label">所属科室：</label>
            <div class="col-sm-3">
               <select id="departmentId" name="departmentId" readonly>
                   <option value="${department.departmentId}">${department.departmentName}</option>
               </select>
            </div>
            <label for="principal" class="col-sm-2 control-label">负责人：</label>
                <div class="col-sm-3">
                    <input type="text" readonly value="${meaningUser.username}" class="form-control" id="principal" name="principal">
                </div>
        </div>
        <div class="form-group col-sm-12">
                <label for="gname" class="col-sm-2 control-label">名称：</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" id="gname" name="gname">
                </div>
                <label for="state" class="col-sm-2 control-label">状态：</label>
                <div class="col-sm-3">
                    <select class="form-control" id="state" name="state">
                        <option value="0">请选择</option>
                        <option value="1">开放</option>
                        <option value="2">关闭</option>
                    </select>
                </div>
        </div>
        <div class="form-group col-sm-12">
            <label for="creatorTimes" class="col-sm-2 control-label">创建时间：</label>
                <div class="col-sm-3">
                    <input type="text" readonly class="form-control" id="creatorTimes" name="creatorTimes" value="">
                </div>
            <label for="telephone" class="col-sm-2 control-label">联系电话：</label>
            <div class="col-sm-3">
                <input type="text" class="form-control" id="telephone" name="telephone" placeholder="请输入联系电话">
            </div>
        </div>
        <div class="form-group col-sm-12">
            <label for="beginTimes" class="col-sm-2 control-label">开始日期：</label>
            <div class="col-sm-3">
                <input type="date" class="form-control" id="beginTimes" name="beginTimes">
            </div>
            <label for="endTimes" class="col-sm-2 control-label">结束日期：</label>
            <div class="col-sm-3">
                <input type="date" class="form-control" id="endTimes" name="endTimes">
            </div>
        </div>
        <div class="form-group col-sm-12">
            <label for="backdrop" class="col-sm-2 control-label">背景：</label>
                <div class="col-sm-8">
                    <textarea class="form-control" rows="3" id="backdrop" name="backdrop"></textarea>
                </div>
        </div>
        <div class="form-group col-sm-12">
            <label for="addGrouptable" class="col-sm-2 control-label"></label>
            <div class="col-sm-8">
                <button id="addGrouptable" type="button" class="btn btn-primary btn-block">保存</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>